package cn.chenxing.module.visualization.service;

import cn.chenxing.domain.dto.TrackLine;
import cn.chenxing.domain.threadlocal.ThreadData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Description 可视化模块服务层
 * @Author maogen.ymg
 * @Date 2020/4/18 11:30
 */
@Service
@Slf4j
public class VisualService {

    /**
     * 传送中心点坐标---用于离群点检测和DBSCAN分析
     * @return 方法名
     */
    public String setStartPoint(String userId) {
        TrackLine trackLine;
        if("所有用户".equals(userId)) {
            trackLine = ThreadData.get().getTrackData().getTrackLineList().get(0);
        }else {
            trackLine = ThreadData.get().getTrackData().getTrackLineList().get(
                    Integer.parseInt(userId)-1);
        }

        if(trackLine == null) {
            // 默认北京 116.40 39.90
            return "getStartPoint('116.40','39.90')";
        }
        double averLon = (trackLine.getLongitudeMax() + trackLine.getLongitudeMin())/2.0;
        double averLat = (trackLine.getLatitudeMax() + trackLine.getLatitudeMin())/2.0;
        return "getStartPoint(" + averLon + ", " + averLat + ")";
    }

    /**
     * 传送缩放级别
     * @return 方法名
     */
    public String setZoomLevel(int zoom) {
        return "setZoom(" + zoom + ")";
    }

}